package com.yufeng.collaboration.service.impl;

import com.yufeng.collaboration.entity.User;
import com.yufeng.collaboration.mapper.UserMapper;
import com.yufeng.collaboration.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;


@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User getUserByUsername(String username) {
        return userMapper.selectOne(new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<User>().eq("username", username));
    }

    @Override
    public boolean validLogin(String username, String password) {
        User user = userMapper.selectOne(new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<User>().eq("username", username).eq("password", password));
        return user != null;
    }

    @Override
    public void registerUser(User user) {
        userMapper.insert(user);
    }

    @Override
    public void modifyUserInfo(User user) {
        userMapper.updateById(user);
    }

   // @Override
//    public User getUserById(Integer userId) {
//        User user = userMapper.selectById(userId);
//        return user;
//    }
}